﻿using System;
using System.Collections.Generic;

using System.Text;
using TimKen.DataAccess;
using TimKen.DataEntity;
using System.Data;

namespace TimKen.BussLogic
{
    /// <summary>
    /// 资源业务逻辑操作类
    /// </summary>
    public class ResourceManager
    {
        private readonly TimKen.DataAccess.ResourceDAO dal = new ResourceDAO();
        public ResourceManager()
        { }
        #region  成员方法

        /// <summary>
        /// 得到最大ID
        /// </summary>


        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string  FileName)
        {
            return dal.Exists(FileName);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(TimKen.DataEntity.Resource model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(TimKen.DataEntity.Resource model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(string FileName)
        {

            dal.Delete(FileName);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TimKen.DataEntity.Resource GetModel(string FileName)
        {

            return dal.GetModel(FileName);
        }

      

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<TimKen.DataEntity.Resource> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List<TimKen.DataEntity.Resource> modelList = new List<TimKen.DataEntity.Resource>();
            int rowsCount = ds.Tables[0].Rows.Count;
            if (rowsCount > 0)
            {
                TimKen.DataEntity.Resource model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new TimKen.DataEntity.Resource();
                    model.FileName = ds.Tables[0].Rows[0]["FileName"].ToString();
                    model.DescriptCN = ds.Tables[0].Rows[0]["DescriptCN"].ToString();
                    model.DescriptEN = ds.Tables[0].Rows[0]["DescriptEN"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(int PageSize, int PageIndex, string strWhere)
        {
            return dal.GetList(PageSize, PageIndex, strWhere);
        }

        public DataSet GetPageList(int pageSize, int PageIndex, string fileName) 
        {
            return dal.GetPageList(pageSize, PageIndex, fileName);
        }

        public DataSet GetPrdctFilePageList(int pageSize, int PageIndex, string fileName) 
        {
            return dal.GetPrdctFilePageList(pageSize, PageIndex, fileName);
        }
        #endregion  成员方法
    }
}
